package com.ly.auth;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

public class Test {
    public static void main(String[] args) {
        String rawPassword = "123456";

        // 创建一个 BCryptPasswordEncoder 实例
        BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();

        // 加密密码
        String encodedPassword = passwordEncoder.encode(rawPassword);

        // 打印加密后的密码
        System.out.println("Encoded Password: " + encodedPassword);

        // 验证密码
        boolean isPasswordMatch = passwordEncoder.matches(rawPassword, encodedPassword);

        // 打印密码验证结果
        System.out.println("Password Matches: " + isPasswordMatch);
    }
}
